package com.example.train_operate.controller;

import com.example.train_operate.entity.Host;
import com.example.train_operate.service.HostService;
import com.example.train_operate.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@Api(tags = "列控主机检修任务接口")
@RequestMapping("/host")
public class HostController {

    @Resource
    private HostService hostService;

    /**
     * 添加列控主机检修任务
     * @param host
     * @return
     */
    @PostMapping("/addHost")
    @ApiOperation("添加列控主机检修任务")
    public Result addHost(@RequestBody Host host){
        return hostService.addHost(host);
    }

    /**
     * 根据id查询列控主机检修任务
     * @param hostId
     * @return
     */
    @GetMapping("/getHostById/{hostId}")
    @ApiOperation("根据id查询列控主机检修任务")
    public Result getHostById(@PathVariable Integer hostId){
        return hostService.getHostById(hostId);
    }

    /**
     * 修改列控主机检修任务
     * @param host
     * @return
     */
    @PutMapping("/updateHost")
    @ApiOperation("修改列控主机检修任务")
    public Result updateHost(@RequestBody Host host){
        return hostService.updateHost(host);
    }
}
